﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;

namespace Business
{
    public partial class Role
    {
        public const string ROOT_ROLE = "Root";
        public const string ADMIN_ROLE = "Admin";
        public const string PGLEADER_ROLE = "PGLeader";
        public const string PG_ROLE = "PG";
        public const string AUDIT_ROLE = "Audit";
    }

    public partial class Role
    {
        public Role(int ID, string Name)
        {
            this.RoleID = ID;
            this.RoleName = Name;
        }
    }

    public partial class Role
    {
        public Common.ERROR_CODE.ERROR_CODE_SIMPLE GetAllForCombo(ref string MesssageSystemError, ref List<Common.ComboItem> ListItem)
        {
            DataClassesDataContext context = null;
            try
            {
                context = new DataClassesDataContext(Common.Global.GetConnectionInfo().ConnectionStringSQL);
                var query = from item in context.Roles
                            select new Common.ComboItem
                            {
                                ID = item.RoleID,
                                Text =  item.RoleName 
                            };
                ListItem = query.ToList();
                return Common.ERROR_CODE.ERROR_CODE_SIMPLE.SUCCESS;
            }
            catch(Exception ex)
            {
                MesssageSystemError = Common.ExceptionUtils.ExceptionToMessage(ex);
                return Common.ERROR_CODE.ERROR_CODE_SIMPLE.SYSTEM_ERROR;
            }
        }
    }

    public class SimpleRole
    {
        private long _ID;
        public long ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        private string _Code = String.Empty;
        public string Code
        {
            get { return _Code; }
            set { _Code = value; }
        }

        private string _Name = String.Empty;
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private string _Description = String.Empty;
        public string Description
        {
            get { return _Description; }
            set { _Description = value; }
        }
    }
}
